home *** CD-ROM | disk | FTP | other *** search
/ Chip 1999 March / CHIP Turkiye Mart 1999.iso / araclar / Win98 / HTML-Tool / DWESD.EXE / data.z / workspace_overview.dcr / Standard_142_search casts script.ls < prev    next >
Encoding:
Text File  |  1998-04-02  |  7.9 KB  |  226 lines

  1. on findpalette castNumber, findCriteria
  2.   if the paramCount < 2 then
  3.     alert("not enough parameters")
  4.   else
  5.     searchCasts(castNumber, findCriteria)
  6.   end if
  7. end
  8.  
  9. on findBitdepth castNumber, findCriteria
  10.   if the paramCount < 2 then
  11.     alert("not enough parameters")
  12.   else
  13.     searchCasts(castNumber, findCriteria)
  14.   end if
  15. end
  16.  
  17. on searchCasts castNumber, searchCriteria
  18.   set foundMembersList to []
  19.   if castNumber = 0 then
  20.     set firstCast to 1
  21.     set lastCast to the number of castLibs
  22.   else
  23.     set firstCast to castNumber
  24.     set lastCast to castNumber
  25.   end if
  26.   repeat with c = firstCast to lastCast
  27.     repeat with m = 1 to the number of castMembers of castLib c
  28.       set currentMember to member m of castLib c
  29.       if the type of currentMember = #bitmap then
  30.         case 1 of
  31.           ((searchCriteria = 0) or (searchCriteria = #all)):
  32.             add(foundMembersList, currentMember)
  33.           ((searchCriteria > 0) and not symbolp(searchCriteria)):
  34.             if the depth of currentMember = searchCriteria then
  35.               add(foundMembersList, currentMember)
  36.             end if
  37.           ((searchCriteria < 0) and not symbolp(searchCriteria)):
  38.             if the depth of currentMember <> abs(searchCriteria) then
  39.               add(foundMembersList, currentMember)
  40.             end if
  41.           (searchCriteria = #mac):
  42.             if the paletteRef of currentMember = #systemMac then
  43.               add(foundMembersList, currentMember)
  44.             end if
  45.           (searchCriteria = #win):
  46.             if the paletteRef of currentMember = #systemWin then
  47.               add(foundMembersList, currentMember)
  48.             end if
  49.           (searchCriteria = #netscape):
  50.             set currentPalette to the paletteRef of member currentMember
  51.             if not symbolp(currentPalette) then
  52.               if the name of member currentPalette = "netscape" then
  53.                 add(foundMembersList, currentMember)
  54.               end if
  55.             end if
  56.           (searchCriteria = #notmac):
  57.             if the depth of member currentMember <> 1 then
  58.               if the paletteRef of currentMember <> #systemMac then
  59.                 add(foundMembersList, currentMember)
  60.               end if
  61.             end if
  62.           (searchCriteria = #notwin):
  63.             if the depth of member currentMember <> 1 then
  64.               if the paletteRef of currentMember <> #systemWin then
  65.                 add(foundMembersList, currentMember)
  66.               end if
  67.             end if
  68.           (searchCriteria = #notnetscape):
  69.             if the depth of member currentMember <> 1 then
  70.               set currentPalette to the paletteRef of member currentMember
  71.               if not symbolp(currentPalette) then
  72.                 if the name of member currentPalette <> "netscape" then
  73.                   add(foundMembersList, currentMember)
  74.                 end if
  75.               else
  76.                 add(foundMembersList, currentMember)
  77.               end if
  78.             end if
  79.         end case
  80.       end if
  81.     end repeat
  82.   end repeat
  83.   if count(foundMembersList) <> 0 then
  84.     outputList(foundMembersList)
  85.     convertList(foundMembersList)
  86.   else
  87.     beep()
  88.     alert("No members were found.")
  89.   end if
  90. end
  91.  
  92. on convertList membersList
  93.   set groupByCastList to seperateIntoCast(membersList)
  94.   set rangeList to seperateIntoRanges(groupByCastList)
  95.   set selectionList to makeSelectionList(rangeList)
  96.   makeSelection(selectionList)
  97. end
  98.  
  99. on seperateIntoCast membersList
  100.   set groupByCastList to [[]]
  101.   set listIndex to 1
  102.   set previousMember to getAt(membersList, 1)
  103.   repeat with m = 1 to count(membersList)
  104.     set currentMember to getAt(membersList, m)
  105.     set currentCastNumber to getCastNumber(currentMember)
  106.     set previousCastNumber to getCastNumber(previousMember)
  107.     if currentCastNumber = previousCastNumber then
  108.       add(getAt(groupByCastList, listIndex), currentMember)
  109.     else
  110.       set listIndex to listIndex + 1
  111.       addAt(groupByCastList, listIndex, [])
  112.       add(getAt(groupByCastList, listIndex), currentMember)
  113.     end if
  114.     set previousMember to currentMember
  115.   end repeat
  116.   return groupByCastList
  117. end
  118.  
  119. on seperateIntoRanges groupByCastList
  120.   set rangeList to []
  121.   repeat with n = 1 to count(groupByCastList)
  122.     set currentList to getAt(groupByCastList, n)
  123.     set range to [getAt(currentList, 1), getAt(currentList, 1)]
  124.     repeat with p = 1 to count(currentList)
  125.       set currentMember to getAt(currentList, p)
  126.       if p < count(currentList) then
  127.         set nextMember to getAt(currentList, p + 1)
  128.       else
  129.         set nextMember to getAt(currentList, p)
  130.       end if
  131.       set currentMemberNumber to getMemberNumber(currentMember)
  132.       set nextMemberNumber to getMemberNumber(nextMember)
  133.       if (currentMemberNumber + 1) = nextMemberNumber then
  134.         setAt(range, 2, nextMember)
  135.         next repeat
  136.       end if
  137.       add(rangeList, range)
  138.       set range to [nextMember, nextMember]
  139.     end repeat
  140.   end repeat
  141.   return rangeList
  142. end
  143.  
  144. on makeSelectionList rangeList
  145.   set initMember to getAt(getAt(rangeList, 1), 1)
  146.   set firstCastNumber to getCastNumber(initMember)
  147.   set selectionList to [:]
  148.   setaProp(selectionList, firstCastNumber, [])
  149.   set previousCastNumber to firstCastNumber
  150.   repeat with r = 1 to count(rangeList)
  151.     set currentRange to getAt(rangeList, r)
  152.     set firstMemberNumber to getMemberNumber(getAt(currentRange, 1))
  153.     set lastMemberNumber to getMemberNumber(getAt(currentRange, 2))
  154.     set currentCastNumber to getCastNumber(getAt(currentRange, 1))
  155.     if currentCastNumber = previousCastNumber then
  156.       add(getProp(selectionList, currentCastNumber), [firstMemberNumber, lastMemberNumber])
  157.       next repeat
  158.     end if
  159.     setaProp(selectionList, currentCastNumber, [[firstMemberNumber, lastMemberNumber]])
  160.     set previousCastNumber to currentCastNumber
  161.   end repeat
  162.   return selectionList
  163. end
  164.  
  165. on makeSelection selectionList
  166.   repeat with d = 1 to the number of castLibs
  167.     set the selection of castLib d to []
  168.   end repeat
  169.   repeat with c = 1 to count(selectionList)
  170.     set the selection of castLib getPropAt(selectionList, c) to getAt(selectionList, c)
  171.   end repeat
  172. end
  173.  
  174. on outputList membersList
  175.   put "Total Members Found:" && count(membersList) & RETURN
  176.   set listOutputString to RETURN & " #   Member Name           Cast                 Palette    Depth" & RETURN
  177.   repeat with m = 1 to count(membersList)
  178.     set currentMember to getAt(membersList, m)
  179.     set memberNumber to getMemberNumber(currentMember)
  180.     set memberName to the name of member currentMember
  181.     set memberName to padString(memberName, 20)
  182.     set castLibName to the name of castLib getCastNumber(currentMember)
  183.     set castLibName to padString(castLibName, 20)
  184.     set memberPalette to the paletteRef of currentMember
  185.     if symbolp(memberPalette) then
  186.       set memberPalette to string(memberPalette)
  187.     else
  188.       set memberPalette to the name of memberPalette
  189.     end if
  190.     set memberPalette to padString(memberPalette, 10)
  191.     set memberBitDepth to the depth of currentMember
  192.     set memberBitDepth to padString(memberBitDepth, 5)
  193.     case 1 of
  194.       (memberNumber < 10):
  195.         set memberNumber to "  " & string(memberNumber)
  196.       (memberNumber < 100):
  197.         set memberNumber to " " & string(memberNumber)
  198.     end case
  199.     put memberNumber & ": " & memberName & "  " & castLibName && memberPalette && memberBitDepth & RETURN after listOutputString
  200.   end repeat
  201.   put listOutputString
  202. end
  203.  
  204. on padString startString, targetLength
  205.   set newString to startString
  206.   if length(startString) > targetLength then
  207.     set newString to char 1 to targetLength - 3 of startString & "..."
  208.     return newString
  209.   end if
  210.   repeat with n = length(startString) + 1 to targetLength
  211.     put " " after newString
  212.   end repeat
  213.   return newString
  214. end
  215.  
  216. on getMemberNumber currentMember
  217.   set memberNumber to word 2 of string(currentMember)
  218.   return value(memberNumber)
  219. end
  220.  
  221. on getCastNumber currentMember
  222.   set castNumber to the last word in string(currentMember)
  223.   set castNumber to value(castNumber)
  224.   return castNumber
  225. end
  226.